package com.atguigu.designpattern.strategy;

/**
* @program: springcloud
* @description: 策略类
* @author: wangjun
* @create: 2021-05-18
**/
public class CashContext {

    private CashSuper cashSuper;

    public CashContext(String type) {
        switch (type){
            case "1":
                cashSuper = new CashNormal();
                break;
            case "2":
                cashSuper = new CashReturn(300.0,100.0);
                break;
            case "3":
                cashSuper = new CashRebate(0.8);
        }
    }

    public double getResult(double money){
        return cashSuper.acceptCash(money);
    }
}
